﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ParserCore;

namespace Memory_Access
{
    public class FunctionTable : AbstractTable
    {
        private Dictionary<Identifier, FunctionImplementation> table;


        public FunctionTable()
        {
            table = new Dictionary<Identifier, FunctionImplementation> ();
        }

        public void AddParsedFunction(FunctionDefinitionStatement function)
        {
            MatlabFunction implementationInfo = new MatlabFunction(function);
            table.Add(function.FcnName, implementationInfo);
        }

        public void AddFunctions(Dictionary<string, string> functions)
        {
            foreach (string name in functions.Keys.AsEnumerable())
            {
                Identifier functionName = new Identifier(name);
                string functionCode;
                functionCode = functions[name];
                //bool success = functions.TryGetValue(name, out functionCode);
                //System.Diagnostics.Debug.Assert(success);
                table.Add(functionName, new MatlabFunction(functionCode));
            }
        }

        public void AddFunctions(FunctionTable funcTable)
        {
        }

        public FunctionImplementation LookUp(Expression ID)
        {
            return null;
        }
    }
}